package com.web.taglibs;
import com.web.checkbox.CheckBoxUtil; 
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import java.io.IOException;

public class ShowCbTag extends TagSupport {
	public int doEndTag() throws JspException {
		StringBuffer buffer = showcheckbox();
		try {
			pageContext.getOut().println(buffer.toString());
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
		return super.doEndTag();
	}

	private StringBuffer showcheckbox() {
		StringBuffer sb = new StringBuffer();
		sb.append("<form method=post action=\"CheckBoxTest.jsp\">\n");    
	    sb.append(CheckBoxUtil.createTreeInfo(CheckBoxUtil.retrieveNodeInfos()));    
	    sb.append("</form>\n");   
		return sb;
	}
}
